/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef GETSCREENSHOT_H
#define GETSCREENSHOT_H

#include <QQuickPaintedItem>
#include <QPainter>
#include <QScreen>
#include <QGSettings/QGSettings>
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
#include <QtQml/qqml.h>
#endif

class GetScreenShot : public QQuickPaintedItem
{
    Q_OBJECT
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
    QML_ELEMENT
#endif
    Q_PROPERTY(QString background READ background WRITE setBackground NOTIFY backgroundChanged)

public:
    GetScreenShot();
    Q_INVOKABLE void paint(QPainter *painter) override;
    Q_INVOKABLE void getScreen();

    QString background() const;
    void setBackground(const QString &background);

Q_SIGNALS:
    void backgroundChanged();

private:
    QScreen *m_screen;
    bool m_flag = false;

    QGSettings* m_backgroundGSettings;
    QString m_url;
    QString m_background;
};

#endif // GETSCREENSHOT_H
